﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace Class_KetNoi
{
    public class KetNoi_ThaiSan:KetNoiCoSoDuLieu
    {
        public void them_ThaiSan(string @MaNV, string @NgayNghiSinh, string @NgayTroLai, string @TroCapCongTy)
        {
            SqlCommand cmd = new SqlCommand("dbo.insert_ThaiSan", cnn);
            cmd.CommandType = CommandType.StoredProcedure;
            SqlParameter p = new SqlParameter("@MaNV",Convert.ToInt32(MaNV));
            cmd.Parameters.Add(p);
            p = new SqlParameter("@NgayNghiSinh", Convert.ToDateTime(NgayNghiSinh));
            cmd.Parameters.Add(p);
            p = new SqlParameter("@NgayTroLai", Convert.ToDateTime(NgayTroLai));
            cmd.Parameters.Add(p);
            p = new SqlParameter("@TroCapCongTy",TroCapCongTy);
            cmd.Parameters.Add(p);
            cmd.ExecuteNonQuery();
                
        }
        public void sua_ThaiSan(string @MaTS, string @MaNV, string @NgayNghiSinh, string @NgayTroLai, string @TroCapCongTy)
        {
            SqlCommand cmd = new SqlCommand("dbo.update_ThaiSan", cnn);
            cmd.CommandType = CommandType.StoredProcedure;
            SqlParameter p = new SqlParameter("@MaTS",MaTS);
            cmd.Parameters.Add(p);
            p = new SqlParameter("@MaNV", Convert.ToInt32(MaNV));
            cmd.Parameters.Add(p);
            p = new SqlParameter("@NgayNghiSinh", Convert.ToDateTime(NgayNghiSinh));
            cmd.Parameters.Add(p);
            p = new SqlParameter("@NgayTroLai", Convert.ToDateTime(NgayTroLai));
            cmd.Parameters.Add(p);
            p = new SqlParameter("@TroCapCongTy", Convert.ToDouble(TroCapCongTy));
            cmd.Parameters.Add(p);
            cmd.ExecuteNonQuery();

        }
        public void xoa_ThaiSan(string @MaTS)
        {
            SqlCommand cmd = new SqlCommand("dbo.delete_ThaiSan", cnn);
            cmd.CommandType = CommandType.StoredProcedure;
            SqlParameter p = new SqlParameter("@MaTS",MaTS);
            cmd.Parameters.Add(p);
            cmd.ExecuteNonQuery();

        }
        public DataTable Load_ThaiSan()
        {
            DataTable dt = new DataTable();
            SqlCommand cmd = new SqlCommand("Load_tbl_ThaiSan",cnn);
            cmd.CommandType = CommandType.StoredProcedure;
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            da.Fill(dt);
            return dt;
        }
    }
}
